package com.blinddate.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blinddate.pojo.entity.Reach;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReachMapper extends BaseMapper<Reach> {
    @Select("SELECT SUM(COUNT) AS count ,SUM(male) AS male,SUM(female) AS female\n" +
            "FROM reach\n" +
            "WHERE DATE_SUB(CURDATE(), INTERVAL #{day} DAY) <= DATE(date_time) AND shop_id = #{value};")
    public Map<String,Object> getTOShopCount(@Param("value") Long shopId, @Param("day") Integer day);

    @Select("SELECT TO_DAYS(NOW())-TO_DAYS(MIN(date_time)) FROM reach where shop_id = #{shop_id}")
    public Integer getMorTime(@Param("shop_id") Long shopId);
}
